# Put employment and well data together.

BEGIN {
  FS = ","
  OFS = ","
  while ((getline line < "/home/huizi/HOLA/research/Green_jobs/data/TX/wellscount_tx.txt") > 0) {
    split (line, x)
    county = x[1]
    year = x[2]
    wells_counts[county,year] = x[3]
    wells_gas[county,year] = x[4]
    wells_oil[county,year] = x[5]
    wells_other[county,year] = x[6]
  }
  print  "RRC", "county", "year", "emp", "wage", "wells", "gas", "oil", "others"
}

{
  if ($2 SUBSEP $3 in wells_counts)
    print $0, wells_counts[$2,$3], wells_gas[$2,$3], wells_oil[$2,$3], wells_other[$2,$3]
  else
    print $0,0,0,0,0

}
